Responding to the appearance of the on-screen keyboard sample


Windows Runtime
User Interface
Windows RT
en-US
11/25/2013

[This documentation is preliminary and is subject to change.]

This sample shows how to listen for and respond to the appearance of the onscreen soft keyboard. When focus is given to an element that requires text input on a device that does not have a dedicated hardware keyboard, the soft keyboard is invoked. You want to make sure that the soft keyboard does not cover the element into which the user is entering text. This sample demonstrates the use of the EnsuredFocusedElementInView property, which specifies that the application has taken steps to ensure that the input pane doesn't cover the UI element that has focus.

The sample demonstrates the following scenario:

  • Adjusting the position of onscreen elements so that they are not obscured by the soft keyboard

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.

Note  For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.

Related topics

Windows.UI.ViewManagement.InputPaneVisibilityEventArgs.ensuredFocusedElementInView
Windows 8 Windows Store app samples

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2

Build the sample

  1. Start Visual Studio 2013 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Microsoft Visual Studio Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

How to use the sample

Click the Show keyboard behavior button, which displays a colorful screen full of many elements arranged in three columns.

When you select the box labeled Tap here to see default keyboard handling (standing in for an input field), the soft keyboard appears on the screen, moving the entire screen contents upward, but still obscuring some of the lowermost elements.

Close the soft keyboard through the keyboard itself.

Select the box labeled Tap here to see custom keyboard handling. Now the elements directly above the input field ("Tap here...") boxes have moved upwards, but the columns to the left and right have remained stationary.